using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: daiduong19051986@gmail.com 
    /// <summary>
    public class TVC_MFMOVControl
    {
        #region Local Variable
        private string business;
        private TVC_MFMOVDataAccess _objDAO;
        #endregion Local Variable

        #region Method


        public TVC_MFMOVControl(String bus)
        {
            business = bus;
            _objDAO = new TVC_MFMOVDataAccess();
        }




        public object BeginTransaction(ref string sErr)
        {
            return _objDAO.BeginTransaction(ref sErr);

        }
        public object GetTransaction()
        {
            return _objDAO.GetTransaction();
        }
        public bool CommitTransaction(ref string sErr)
        {
            return _objDAO.CommitTransaction(ref sErr);
        }
        public bool RollbackTransaction(ref string sErr)
        {
            return _objDAO.RollbackTransaction(ref sErr);

        }
        public void SetTransaction(object o)
        {
            _objDAO.SetTransaction(o);
        }


        public TVC_MFMOVInfo Get(string db, String Code, ref string sErr)
        {
            return _objDAO.Get(db, Code, ref sErr);
        }

        public DataTable GetAll(string db, ref string sErr)
        {
            return _objDAO.GetAll(db, ref sErr);
        }

        public Int32 Add(string db, TVC_MFMOVInfo obj, ref string sErr)
        {
            return _objDAO.Add(db, obj, ref sErr);
        }

        public string Update(string db, TVC_MFMOVInfo obj, bool isamt = true)
        {
            return _objDAO.Update(db, obj, isamt);
        }

        public string Delete(string db, String Code)
        {
            return _objDAO.Delete(db, Code);
        }
        public Boolean IsExist(string db, String Code)
        {
            return _objDAO.IsExist(db, Code);
        }

        public string InsertUpdate(string db, TVC_MFMOVInfo obj)
        {
            string sErr = "";
            if (IsExist(db, obj.Code))
            {
                sErr = _objDAO.Update(db, obj);
            }
            else _objDAO.Add(db, obj, ref sErr);
            return sErr;
        }

        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
            TVC_MFMOVInfo inf = new TVC_MFMOVInfo();
            return inf.ToDataTable();
        }

        public string TransferIn(string db, DataRow row)
        {
            TVC_MFMOVInfo inf = new TVC_MFMOVInfo(row);
            return InsertUpdate(db, inf);
        }
        #endregion Method


        public DataTable GetBalance(string db, string ItemCode, ref string sErr)
        {
            return _objDAO.GetBalance(db, ItemCode, ref sErr);
        }

        public bool ItemCodeIsExist(string db, string ItemCode)
        {
            return _objDAO.ItemCodeIsExist(db, ItemCode);
        }

        public DataTable GetbyReference(string db, string Reference, string isHold, ref string sErr)
        {
            return _objDAO.GetbyReference(db, Reference, isHold, ref sErr);
        }

        public DataTable GetbyReferenceList(string db, string Reference, string isHold, ref string sErr)
        {
            return _objDAO.GetbyReferenceList(db, Reference, isHold, ref sErr);
        }
        public void DeleteRef(string db, string Reference)
        {
            _objDAO.DeleteRef(db, Reference);
        }

        public TVC_MFMOVInfo GetbyItemCode(string db, string ItemCode, ref string sErr)
        {
            return _objDAO.GetbyItemCode(db, ItemCode, ref sErr);
        }

        public DataTable GetHold(string db, string Hold, ref string sErr)
        {
            return _objDAO.GetHold(db, "Y", ref sErr);
        }


        public DataTable GetbyFilter(string db, string strFilter, ref string sErr)
        {
            return _objDAO.GetbyFilter(db, strFilter, ref sErr);
        }
        public DataTable GetbyFilterList(string db, string strFilter, ref string sErr)
        {
            return _objDAO.GetbyFilterList(db, strFilter, ref sErr);
        }
        public DataTable GetQuery(string query, ref string sErr)
        {
            return _objDAO.GetQuery(query, ref sErr);
        }

        public string UpdateRef(string db, TVC_MFMOVInfo info)
        {
            return _objDAO.UpdateRef(db, info);
        }

        public string UpdateTransit(string db, string code, DateTime ConfirmDate, string transit)
        {
            return _objDAO.UpdateTransit(db, code, ConfirmDate, transit);
        }
        public string UpdateVerified(string db, string Reference, string Verified)
        {
            return _objDAO.UpdateVerified(db, Reference, Verified);
        }


        public bool HasRefInPost(string db, string refer, string moveType)
        {
            return _objDAO.HasRefInPost(db, refer, moveType);
        }
        public bool Has2Ref(string db, string refer, string moveType)
        {
            return _objDAO.Has2Ref(db, refer, moveType);
        }


        public DataTable GetItemSumByRef(string db, string refer, ref string sErr)
        {
            return _objDAO.GetItemSumByRef(db, refer, ref sErr);
        }

        public bool HasRefInUsed(string db, string refer)
        {
            return _objDAO.HasRefInUsed(db, refer);
        }

        public DataTable GetHeld(string db, string Held, ref string sErr)
        {
            return _objDAO.GetHeld(db, Held, ref sErr);
        }
        public DataTable GetPost(string db, ref string sErr)
        {
            return _objDAO.GetPost(db, ref sErr);
        }

        public DataTable GetVerify(string db, ref string sErr)
        {
            return _objDAO.GetVerify(db, ref sErr);
        }

        public DataTable GetMaxPostCode(string db, ref string sErr)
        {
            return _objDAO.GetMaxPostCode(db, ref sErr);
        }

        public DataTable GetMaxCode(string db, ref string sErr)
        {
            return _objDAO.GetMaxCode(db, ref sErr);
        }

        public DataTable GetSumQtyLocation(string db, string ItemCode, string Location, ref string sErr)
        {
            return _objDAO.GetSumQtyLocation(db, ItemCode, Location, ref sErr);
        }

        public List<string> GetReferenceNotSun(string db, ref string sErr)
        {
            return _objDAO.GetReferenceNotSun(db, ref sErr);
        }

        public List<string> GetSunReference(string db, List<string> refs, string sunConnect, ref string sErr)
        {
            return _objDAO.GetSunReference(db, refs, sunConnect, ref sErr);
        }

        public void updSunStatus(string db, string refer, string status, ref string sErr)
        {
            _objDAO.updSunStatus(db, refer, status, ref sErr);
        }
    }
}
